set(KLAYGE_CMAKE_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Build/CMake/Modules")
list(APPEND CMAKE_MODULE_PATH "${KLAYGE_CMAKE_MODULE_DIR}")

cmake_minimum_required(VERSION 3.16 FATAL_ERROR)

project(KlayGE)

set(KLAYGE_MAJOR_VERSION 4)
set(KLAYGE_MINOR_VERSION 18)
set(KLAYGE_PATCH_VERSION 0)
set(KLAYGE_VERSION ${KLAYGE_MAJOR_VERSION}.${KLAYGE_MINOR_VERSION}.${KLAYGE_PATCH_VERSION})

set(KLAYGE_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")

set(CMAKE_DEBUG_POSTFIX "_d" CACHE STRING "")
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "")
set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "")
set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "")

find_package(Python3 COMPONENTS Interpreter REQUIRED)

include(${KLAYGE_CMAKE_MODULE_DIR}/Dependencies.cmake)
include(${KLAYGE_CMAKE_MODULE_DIR}/Platform.cmake)
include(${KLAYGE_CMAKE_MODULE_DIR}/Compiler.cmake)
include(${KLAYGE_CMAKE_MODULE_DIR}/Config.cmake)

set(KLAYGE_BIN_DIR "${KLAYGE_ROOT_DIR}/KlayGE/bin/${KLAYGE_PLATFORM_NAME}")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${KLAYGE_BIN_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${KLAYGE_BIN_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${KLAYGE_BIN_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${KLAYGE_BIN_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${KLAYGE_BIN_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${KLAYGE_BIN_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${KLAYGE_BIN_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${KLAYGE_BIN_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${KLAYGE_BIN_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${KLAYGE_BIN_DIR})

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

add_subdirectory(Externals EXCLUDE_FROM_ALL)
add_subdirectory(glloader EXCLUDE_FROM_ALL)
add_subdirectory(KFL)
add_subdirectory(DXBC2GLSL EXCLUDE_FROM_ALL)
add_subdirectory(kfont)
add_subdirectory(KlayGE)
